import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  HttpException,
  HttpStatus,
} from '@nestjs/common';
import { HttpexceptionService } from './httpexception.service';
import { CreateHttpexceptionDto } from './dto/create-httpexception.dto';
import { UpdateHttpexceptionDto } from './dto/update-httpexception.dto';
import { ApiTags } from '@nestjs/swagger';
@ApiTags('异常测试')
@Controller('httpexception')
export class HttpexceptionController {
  constructor(private readonly httpexceptionService: HttpexceptionService) {}

  @Post()
  create(@Body() createHttpexceptionDto: CreateHttpexceptionDto) {
    return this.httpexceptionService.create(createHttpexceptionDto);
  }

  @Get()
  findAll() {
    throw (
      (new HttpException('Forbidden', HttpStatus.FORBIDDEN),
      {
        cause: { name: '红色', message: '000' },
        description: '不行',
      })
    );
    // return this.httpexceptionService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.httpexceptionService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateHttpexceptionDto: UpdateHttpexceptionDto,
  ) {
    return this.httpexceptionService.update(+id, updateHttpexceptionDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.httpexceptionService.remove(+id);
  }
}
